# Maintainer: Alexey Kasatkin <alexeikasatkin@gmail.com>
# ArchLinux maintainer: Jaroslav Lichtblau <dragonlord@aur.archlinux.org>
# Contributor: Brian Galey <bkgaley at gmail dot com>
# Contributor: Bruno Gola <brunogola at gmail dot com>

_realname=libfreexl
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.0.5
pkgrel=1
pkgdesc="Library to extract valid data from within an Excel (.xls) spreadsheet (mingw-w64)"
arch=('any')
url="https://www.gaia-gis.it/fossil/freexl"
license=('MPL' 'GPL' 'LGPL')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-libiconv")
options=(strip)
source=("https://www.gaia-gis.it/gaia-sins/freexl-${pkgver}.tar.gz"
        "01-fix-pkgconfig.patch")
sha256sums=('3dc9b150d218b0e280a3d6a41d93c1e45f4d7155829d75f1e5bf3e0b0de6750d'
            'bc6facd7b0bde308d442962b350fa1894cd6605412ae4665775be745069e4ea5')

prepare() {
  cd "${srcdir}/freexl-${pkgver}"
  patch -p1 -i ${srcdir}/01-fix-pkgconfig.patch
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  ../freexl-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX}
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install
}
